package com.mytech.cslive.commands;

public class CommandParameter {
	private static final char PARAMETERS_VALUE_SEPERATOR = ',';
	private static final char PARAMETER_VALUE_ASSIGNMENT = '=';
	
	private String name;
	private String[] values;
	
	public CommandParameter(String name, String... values) {
		this.name = name;
		this.values = values;
	}

	protected static char getParametersValueSeperator() {
		return PARAMETERS_VALUE_SEPERATOR;
	}

	protected static char getParameterValueAssignment() {
		return PARAMETER_VALUE_ASSIGNMENT;
	}
	
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String[] getValues() {
		return values;
	}

	public void setValues(String[] values) {
		this.values = values;
	}
	
	@Override
	public String toString() {
		String parameter = this.getName() + getParameterValueAssignment();
		
		for (int index = 0; index < values.length; index++) {
			parameter = parameter + values[index] + getParametersValueSeperator();
		}
		
		// Erase last parameter value seperator
		parameter = parameter.substring(0, parameter.length() - 1);
		
		return (parameter);
	}
}
